<?php if (!defined('DB_PEREFIX')) exit;

global $_POST, $db, $GLOBAL_USER;

$get_online = $db->query ("SELECT * FROM ".DB_PEREFIX."_sessions");
$total = $db->num_rows ($get_online);
$user_line = "";
$guest_ip = "";
$u = 0;
$g = 0;
while ($user = $db->fetch_array ($get_online)) {
	if ($user['uid'] != "" && $u <= 20) {
		$select_user = $db->query ("SELECT user_name FROM ".DB_PEREFIX."_users WHERE user_id = '".$user['uid']."'");
		if ($db->num_rows($select_user) > 0) {
			$user_ = $db->fetch_array ($select_user);
			$user_line .= "\n<tr><td width=70%>&#8212; <a href=\"admin.php?name=users&id=".$user['uid']."\"></small>".$user_['user_name']."</small></a> <small>(<a href='http://www.nic.ru/whois/?ip=".$user['uip']."' target=_blank><small>".$user['uip']."</small></a>)</small></td><td><small>".$user['page']."</small></td></tr>";
			$u++;
		}
	}
	if ($user['ugroup'] == "guest" && $g <= 20) {
		$guest_ip .= "\n<small>&#8212; [ <a href='http://www.nic.ru/whois/?ip=".$user['uip']."' target=_blank><small>".$user['uip']."</small></a> - ".$user['page']." ]<small><br />";
		$g++;
	}
}
$get_guest_online = $db->num_rows ($db->query ("SELECT * FROM ".DB_PEREFIX."_sessions WHERE ugroup = 'guest'"));
$get_users_online = $db->num_rows ($db->query ("SELECT * FROM ".DB_PEREFIX."_sessions WHERE ugroup = 'user'"));

print "Всего пользователей on-line: $total (пользователи: $get_users_online, гости: $get_guest_online)<p /><strong>Пользователи:</strong>
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpaddin=\"2\">
$user_line
<tr><td colspan=\"2\"><br><strong>Гости:</strong><br>$guest_ip</td></tr>
</table><center><a href=\"admin.php?mod=clear_sessions\">Очистить</a></center>";

exit;

?>
